package com.ruoyi.api.event;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Map;
import java.util.HashMap;

/**
 * 订单执行事件
 */
public class OrderExecutionEvent implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 事件类型
     */
    private EventType eventType;
    
    /**
     * 订单ID
     */
    private Long orderId;
    
    /**
     * 订单编号
     */
    private String orderCode;
    
    /**
     * 商品ID - 便于库存模块直接获取
     */
    private Long productId;
    
    /**
     * 商品名称 - 便于库存模块直接获取
     */
    private String productName;
    
    /**
     * 数量 - 便于库存模块直接获取
     */
    private Integer quantity;
    
    /**
     * 订单金额
     */
    private BigDecimal totalAmount;
    
    /**
     * 事件相关数据（如供应商ID、客户ID等）
     */
    private Map<String, Object> data = new HashMap<>();

    public OrderExecutionEvent() {
    }

    public OrderExecutionEvent(EventType eventType, Long orderId) {
        this.eventType = eventType;
        this.orderId = orderId;
    }

    public EventType getEventType() {
        return eventType;
    }

    public void setEventType(EventType eventType) {
        this.eventType = eventType;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public String getOrderCode() {
        return orderCode;
    }

    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }
    
    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }
    
    public void setTotalAmount(Double totalAmount) {
        if (totalAmount != null) {
            this.totalAmount = BigDecimal.valueOf(totalAmount);
        }
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }
    
    public void addData(String key, Object value) {
        this.data.put(key, value);
    }
    
    public Object getData(String key) {
        return this.data.get(key);
    }
} 